package com.slkj.shilixiaoyuanapp.ui.find;

import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.slkj.shilixiaoyuanapp.R;
import com.slkj.shilixiaoyuanapp.base.ActivityInfo;
import com.slkj.shilixiaoyuanapp.base.BaseActivity;
import com.slkj.shilixiaoyuanapp.entity.MyclassEntity;
import com.slkj.shilixiaoyuanapp.view.MySwipeRefreshLayout;
import com.slkj.shilixiaoyuanapp.view.dialog.LoadSuccessAndFailDialog;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

@ActivityInfo(layout = R.layout.message_list_activity)
public class MessageListActivity extends BaseActivity implements SwipeRefreshLayout.OnRefreshListener, MessageListAdapter.onDeleteLisener, BaseQuickAdapter.OnItemClickListener {
    @BindView(R.id.message_list_refresh)
    MySwipeRefreshLayout refreshLayout;
    @BindView(R.id.message_list_recycer)
    RecyclerView recyclerView;

    private List<MyclassEntity> list = new ArrayList<>();
    private MessageListAdapter adapter;
    @Override
    protected void init() {
        refreshLayout.setColorSchemeColors(getResources().getColor(R.color.color_green));
        recyclerView.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false));
        recyclerView.setItemAnimator(new DefaultItemAnimator());
        list.add(new MyclassEntity("一年级八班",true));
        list.add(new MyclassEntity("一年级十八班",false));
        adapter = new MessageListAdapter(list,this);
        recyclerView.setAdapter(adapter);
        initListener();
    }

    private void initListener() {
        refreshLayout.setOnRefreshListener(this);
        adapter.setOnItemClickListener(this);
        adapter.setLisener(this);
    }

    @Override
    public void onRefresh() {
        list.add(new MyclassEntity("一年级八班",false));
        list.add(new MyclassEntity("一年级十八班",false));
        adapter.notifyDataSetChanged();
        refreshLayout.setRefreshing(false);
    }

    @Override
    public void OnDelete() {
        showToast("删除");
    }

    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        //showToast("查看详情"+position);
        LoadSuccessAndFailDialog.showSuccess(MessageListActivity.this,"查看详情"+position);
    }
}
